window.onload = function(){
        var btn = document.getElementById("register");
        btn.onclick = function(){
            var name = document.getElementById("username");
            var number=document.getElementById("number");
            var faculty=document.getElementById("faculty");
            var phone = document.getElementById("phoneNumber");
            var identity=document.getElementById("identity");
            var password = document.getElementById("password");
            var repassword = document.getElementById("repassword");
            var reg = /^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8])|(19[7]))\d{8}$/
            if(username.value == ""){
                alert("用户名不能为空!");
                return 0;
            } else if (phone.value == ""){
                alert("手机号不能为空!");
                return 0;
            } else if (password.value == ""){
                alert("密码不能为空");
                return 0;
            }
            if(!reg.test(phone.value)){
                alert("手机号格式不对");
                return 0;
            } else if (password.value!=repassword.value){
                alert("两次密码不一致!");
                return 0;
            }
            var data={
                phone:phone.value,
                password:password.value,
                faculty:faculty.value,
                identity:identity.value,
                name:name.value,
                number:number.value
            };
            $.ajax({
                type:"post",
                dataType:"text",
                url:"/fp_war_exploded/register",
                data:JSON.stringify(data),
                success:function (result) {
                    if(result.match("success")){
                        alert("注册成功");
                        window.location.href="login.html";
                        sessionStorage.setItem("number1",number.value);
                    }
                    else {
                        alert("注册失败");
                    }
                },
                error:function () {
                    alert("error");
                }
            });

        }
    }
